<include file="Public/header"/>
<div class="row">
    <div class="col-md-12">
        <div class="ibox float-e-margins">

            <div class="ibox-title">
                <h5>阿里大鱼短信企业版设置</h5>
                <div class="row">
                    <div class="col-sm-2 pull-right">
                        <a href="<{:U('System/smsTemplateList')}>" class="layui-btn layui-btn-small" >短信模版</a>
                    </div>
                </div>
            </div>
            <div class="ibox-content">
                <form class="layui-form" action="" autocomplete="off" id="baseForm">
                    <input type="hidden" name="id" id="id" value="<{$vo.id}>">
                    <div class="layui-form-item">
                        <label class="layui-form-label">App Key：</label>
                        <div class="layui-input-block">
                            <input type="text" name="app_key" value="<{$vo.app_key}>" placeholder="App Key" lay-verify="required" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">App Secret：</label>
                        <div class="layui-input-block">
                            <input type="text" name="app_secret" value="<{$vo.app_secret}>" placeholder="" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信签名：</label>
                        <div class="layui-input-block">
                            <input type="text" name="sign_name" value="<{$vo.sign_name}>" placeholder="" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">短信设置：</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_open" value="1" title="开启" <if
                                condition="$vo['is_open'] eq 1">checked
                        </if>>
                            <input type="radio" name="is_open" value="0" title="关闭" <if
                                condition="$vo['is_open'] eq 0">checked
                        </if>>
                        </div>
                    </div>
                    <!-- <div class="layui-form-item">
                        <label class="layui-form-label">接收通知手机：</label>
                        <div class="layui-input-block">
                            <input type="text" name="admin_mobile" value="<{$vo.admin_mobile}>" placeholder="请输入管理员接收通知的手机号"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">管理员通知：</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_receive" value="1" title="开启" <if
                                condition="$vo['is_receive'] eq 1">checked
                        </if>>
                            <input type="radio" name="is_receive" value="0" title="关闭" <if
                                condition="$vo['is_receive'] eq 0">checked
                        </if>>
                        </div>
                    </div> -->


                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
                <hr/>
                <div class="layui-form-item" style="margin-top: 50px;">
                    <label class="layui-form-label">测试接收手机：</label>
                    <div class="layui-input-inline">
                        <input type="mobile" autocomplete="off" class="layui-input" id="cs_text" name="cs_text" value=""  placeholder="例如：13800138000">
                    </div>
                    <div class="layui-input-inline">
                        <button class="layui-btn" lay-submit="" onclick="sendMobile()">测试发送短信</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="Public/footer"/>
<script>
    layui.use(['form', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,laydate = layui.laydate;
        //自定义验证规则
        form.verify({

        });
        //监听提交
        form.on('submit(add)', function(data){
            $.ajax({
                url:"<{:U('System/saveSms')}>",
                type:"post",
                data:$('#baseForm').serialize(),
                success:function(res){
                    if(res.status){
                        layer.alert("操作成功", {icon: 6},function () {
                            location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg("操作失败!", {icon: 5},function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                        return false;
                    }
                }
            });
            return false;
        });
    });
    function sendMobile() {
        $.ajax({
            url:"<{:U('System/testMobile')}>",
            type:"post",
            data:'cs_text='+$('#cs_text').val(),
            success:function(res){
                if(res.status){
                    layer.alert(res.msg, {icon: 6},function () {
                        location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }else{
                    layer.msg(res.msg, {icon: 6},function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                    return false;
                }
            }
        });
    };
</script>
</body>
</html>